package com.region.integral.common_user.consume.dao.delegate;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.region.integral.common_user.consume.dao.IBuildGroup;
import com.region.integral.common_user.consume.dao.IExchangeK;
import com.region.integral.common_user.consume.dao.IUnsubscribeGoods;
import com.region.integral.common_user.obtain.vo.IntegralData;
import com.region.integral.exception.IntegralException;

@Component("consume_regulationObjectDelegate")
public class RegulationObjectDelegate {
	@Resource(name="iBuildGroup")
	private IBuildGroup iBuildGroup;
	@Resource(name="iExchangeK")
	private IExchangeK iExchangeK;
	@Resource(name="iUnsubscribeGoods")
	private IUnsubscribeGoods iUnsubscribeGoods;
	
	public boolean buildGroupDelegate(int userid){
		IntegralData integralData = new IntegralData();
		try {
			iBuildGroup.buildGroup(userid, integralData);
		} catch (IntegralException e) {
			e.printStackTrace();
		}
		return integralData.isSuccee();
	}
	public boolean exchangeKDelegate(int userid,int KexchangeNum){
		IntegralData integralData = new IntegralData();
		try {
			iExchangeK.exchangeK(userid, KexchangeNum, integralData);
		} catch (IntegralException e) {
			e.printStackTrace();
		}
		return integralData.isSuccee();
	}
	public String unsubscribeGoodsDelegate(int userid){
		IntegralData integralData = new IntegralData();
		try {
			iUnsubscribeGoods.unsubscribeGoods(userid, integralData);
		} catch (IntegralException e) {
			e.printStackTrace();
		}
		return integralData.getMessage();
	}
	
}